package com.acwing.partition43;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/5/22 8:56
 */
public class AC4262空调 {

    private static final int N = 100010;
    private static int[] a = new int[N];
    private static int n;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        for (int i = 1; i <= n; i++) a[i] = nextInt();
        for (int i = 1; i <= n; i++) a[i] -= nextInt();
        //计算差分数组
        for (int i = n; i > 0; i--) a[i] -= a[i - 1];
        int pos = 0, neg = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] > 0) pos += a[i];
            else neg -= a[i];
        }
        writer.println(Math.max(pos, neg));
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
